package com.hgd.igreencar.nettytest;

import com.hgd.igreencar.entity.Letout;
import com.hgd.igreencar.entity.RpcRequest;
import com.hgd.igreencar.entity.VehicleExhaust;
import io.netty.channel.Channel;

import java.util.UUID;

public class ClientMain {
    public static void main(String[] args) throws Exception {
        NettyClient client = new NettyClient("127.0.0.1", 8080);

        //启动client服务
        client.start();

        Channel channel = client.getChannel();

        //消息体
        RpcRequest request = new RpcRequest();
        request.setId(UUID.randomUUID().toString());
        request.setData("client.message");
        request.setCount(1);
        request.setSpeed(250);
        VehicleExhaust vehicleExhaust = new VehicleExhaust();
        vehicleExhaust.setCarId("21");
        vehicleExhaust.setLetout(8);
        vehicleExhaust.setLetoutId("1");

        request.setVehicleExhaust(vehicleExhaust);

        //channel对象可以保存在map中，供在其他地方发送消息
        channel.writeAndFlush(request);
    }
}
